<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<!-- <base href="http://192.168.0.100:8080/YMGW/"> -->
<title>超市后台</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">

<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>

<script>
	$(function() {
		$("#supermarketId").val(localStorage.getItem("id"));
		$.post(urls +"productaAction/getSupermarketSet",
			{
				superID : localStorage.getItem("id")
			},
			function(data) {
			//console.log(data)
			   $("input[name='agentId']").val(data.agentId);
				$("input[name='upSendMoney']").val(data.upSendMoney);
				$("input[name='freeSendMoney']").val(data.freeSendMoney);
				$("input[name='sendMoney']").val(data.sendMoney);
				$("input[name='sendPeople']").val(data.sendPeople);
				$("input[name='sendTime']").val(data.sendTime);
				$("input[name='superName']").val(data.superName);
				$("textarea[name='afterService']").val(data.afterService);
				$("input[name='sendPhone']").val(data.sendPhone);
			}, "json");
	})
</script>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>开店设置</span>
					</div>
					<form class="form-horizontal" id="uploadForm"
						style="margin-top: 30px">
						<div class="form-group">
							<label class="col-xs-1 control-label">起送金额</label>
							<div class="col-xs-3">
								<input class="form-control" id="upSendMoney" name="upSendMoney"
									placeholder="请输入起送金额">
							</div>
							<label class="col-xs-1 control-label" style="text-align: left">元起送</label>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">满：</label>
							<div class="col-xs-3">
								<input class="form-control" id="freeSendMoney" name="freeSendMoney"
									placeholder="请输入满多少价格免配送费">
							</div>
							<label class="col-xs-1 control-label" style="text-align: left">元免配送费</label>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">配送费</label>
							<div class="col-xs-3">
								<input class="form-control" id="sendMoney" name="sendMoney" placeholder="请输入配送费">
							</div>
							<label class="col-xs-1 control-label" style="text-align: left">元</label>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">超市名称</label>
							<div class="col-xs-3">

								<input class="form-control" id="superName" name="superName" placeholder="请输入超市名称">
								<input name="supermarketId" style="display:none"
									id="supermarketId" />
									<input name="agentId" style="display:none"
									id="agentId" />

							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">配送人</label>
							<div class="col-xs-3">
								<input class="form-control" id="sendPeople" name="sendPeople"
									placeholder="请输入配送人名称">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">配送电话</label>
							<div class="col-xs-3">
								<input class="form-control" id="sendPhone" name="sendPhone"
									placeholder="请输入配送员电话">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">配送时间</label>
							<div class="col-xs-3">
								<input class="form-control" id="sendTime" name="sendTime" placeholder="请输入配送时间">
							</div>
							<label class="col-xs-1 control-label" style="text-align: left">如
								8:30-22:30</label>
						</div>
						<div class="form-group">
							<label class="col-xs-1 control-label">售后服务</label>
							<div class="col-xs-3">
								<textarea class="col-xs-12" rows="5" id="afterService" name="afterService"></textarea>
							</div>

						</div>
						<div class="form-group">
							<div class="col-xs-2 col-xs-offset-2">
								<button type="button" onclick="superSet()"
									class="col-xs-4 btn btn-primary">修改</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
	<script>
		function superSet() {
		//alert($("#agentId").val())
			var allInput = $("#uploadForm").find("input");
			var config = true;
			for (var ids = 0; ids < allInput.length; ids++) {
				if (allInput[ids].value) {
				} else {
					config = false;
				}
			}
			if (!$("#afterService").val()) {
				config = false;
			}
			if (config) {
				$.post(urls +"productaAction/setSupermarketSet",
					{
					agentId:$("#agentId").val(),
						upSendMoney:$("#upSendMoney").val(),
						freeSendMoney:$("#freeSendMoney").val(),
						sendPeople:$("#sendPeople").val(),
						superName:$("#superName").val(),
						sendTime:$("#sendTime").val(),
						afterService:$("#afterService").val(),
						sendPhone:$("#sendPhone").val(),
						sendMoney:$("#sendMoney").val(),
						supermarketId:$("#supermarketId").val(),
						status:2,
					},
					function(res) {
						//console.log(res)
						if (res == true) {
							alert("修改成功")
						} else {
							alert("提交失败")
						}
					}
				)
			} else {
				alert("请填写完整信息再确认修改")
			}
		}
	</script>
</body>
</html>
